
public class MyModTwo3 {

	public static void main(String[] args) {
		int[] qu = new int[] { 12, 65, 97 };
		int num = 23;
		int a, b, c, d;
		for (int q : qu) {
			if ((a = getBinForm(q + num)) == (b = getBinForm(q)) + (c = getBinForm(num))) {
				System.out.println(num + "与" + q + "模二相加不变");
				System.out.println("因为" + q + "+" + num + "=" + (q + num) + " 模二数为" + Integer.toBinaryString(a));
				System.out.println("因为" + num + "模二数为" + Integer.toBinaryString(c));
				System.out.println("因为" + q + "模二数为" + Integer.toBinaryString(b));
			}
		}
		int count = 0;
		for (int i = 10; i < 100; i++) {
			if ((a = getBinForm(i + num)) == (b = getBinForm(i)) + (c = getBinForm(num))) {
				count++;
				System.out.print(i + ",");
			}
		}
		System.out.println("");
		System.out.println("两位数与23模二数不变的有：");
		System.out.println(count);
	}

	public static int getBinForm(int target) {
		int ans = 0;
		int move = 0;
		while (target > 0) {
			int cur = target % 10;
			int mod = cur % 2;
			if (mod == 1) {
				ans |= 1 << move;
			}
			move++;
			target /= 10;
		}
		return ans;
	}

}
